{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=maplibre/H3.ipynb)\n",
    "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/opengeos/leafmap/blob/master/docs/maplibre/H3.ipynb)\n",
    "[![image](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/opengeos/leafmap/HEAD)\n",
    "\n",
    "**H3 Hexagonal Grid**\n",
    "\n",
    "\n",
    "Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# %pip install leafmap"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import leafmap.maplibregl as leafmap"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "url = \"https://data.gishub.org/duckdb/h3_res4_geo.parquet\"\n",
    "gdf = leafmap.read_vector(url)\n",
    "gdf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "m = leafmap.Map()\n",
    "m.add_basemap(\"Esri.WorldImagery\", before_id=m.first_symbol_layer_id, visible=False)\n",
    "m.add_data(\n",
    "    gdf,\n",
    "    column=\"building_count\",\n",
    "    scheme=\"JenksCaspall\",\n",
    "    cmap=\"inferno\",\n",
    "    outline_color=\"rgba(255, 255, 255, 0)\",\n",
    "    name=\"H3 Hexagon\",\n",
    "    before_id=m.first_symbol_layer_id,\n",
    ")\n",
    "m"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](https://github.com/user-attachments/assets/4b489d3f-1ed8-4648-b797-90d7e98b08db)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "m = leafmap.Map(center=[7.062832, -4.144790], pitch=45.5, zoom=1.57)\n",
    "m.add_basemap(\"Esri.WorldImagery\", before_id=m.first_symbol_layer_id, visible=False)\n",
    "m.add_data(\n",
    "    gdf,\n",
    "    column=\"building_count\",\n",
    "    scheme=\"JenksCaspall\",\n",
    "    cmap=\"inferno\",\n",
    "    outline_color=\"rgba(255, 255, 255, 0)\",\n",
    "    name=\"H3 Hexagon\",\n",
    "    before_id=m.first_symbol_layer_id,\n",
    "    extrude=True,\n",
    "    fit_bounds=False,\n",
    ")\n",
    "m"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](https://github.com/user-attachments/assets/68fb9893-5e3e-40a9-bd43-8a5e3a6d595b)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "geo",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
